﻿//09.Write a program that deletes from given text file all odd lines. The result should be in the same file.

using System;
using System.Collections.Generic;
using System.IO;

namespace DeleteOddLines
{
    class DeleteOddLines
    {
        static void Main()
        {
            string filename = "oddlines.txt";
            StreamReader sr = new StreamReader(filename);
            string row = sr.ReadLine();
            int count = 0;
            List<string> rows = new List<string>();
            while (row != null)
            {

                if (count % 2 == 0)
                {
                    rows.Add(row);
                }
                row = sr.ReadLine();
                count++;
            }
            sr.Close();

            StreamWriter sw = new StreamWriter(filename, false);
            for (int i = 0; i < rows.Count; i++)
            {
                sw.WriteLine(rows[i]);
            }
            sw.Close();
        }
    }
}
